package com.yeung.exam;

import java.util.Scanner;

public class 字节_正负数相隔 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] data = sc.nextLine().split(" ");
        int[] intData = new int[data.length];
        for (int i = 0; i < data.length; i++) {
            intData[i] = Integer.parseInt(data[i]);
        }
        if (data.length <= 1) {
            System.out.println(data[0]);
            return;
        }
        int start = 0;

//        int right = 0;
        while (start < data.length - 1) {

            if (!isAgainst(intData[start], intData[start + 1])) {//是否前后两数符号相异
                boolean firstIsPos = (intData[start + 1] < 0) ? true : false;//第一个为负数,后边就扫面正数 ,否则相反
                int index = find(intData, start + 1, firstIsPos);//往后找负数
                if (index == -1) break;
                    //后边没有负数了
                else {
                    int end = index;
                    move(intData, start + 1, index);
                }
            }
            if (intData[0] < 0) {
                int tmp = intData[start];
                intData[start] = intData[start + 1];
                intData[start + 1] = tmp;
            }
                start++;

        }
        //输出结果
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < intData.length; i++) {
            sb.append(intData[i] + " ");
        }
        System.out.println(sb.deleteCharAt(sb.length() - 1).toString());
    }

    static boolean isAgainst(int a, int b) {
        if (a >= 0 && b < 0 || a < 0 && b >= 0) return true;
        return false;
    }

    static void move(int[] data, int start, int end) {
        int tmp = data[end];
        for (; end > start; end--) {
            data[end] = data[end - 1];
        }
        data[start] = tmp;
    }

    static int find(int data[], int start, boolean findPos) {
        int targetIndex = -1;
        for (int i = start + 1; i < data.length; i++) {
            //找正数
            if (data[i] > 0 && findPos) {
                targetIndex = i;
                break;
            }
            //找负数
            if (data[i] < 0 && !findPos) {
                targetIndex = i;
                break;
            }

        }
        return targetIndex;
    }

}
